#ifndef HDAFLOWMANAGER_H
#define HDAFLOWMANAGER_H

#include <QObject>
#include <QVector>
#include "HdaOperationThread.h"
#include "Page.h"
#include "HdaProgressBar.h"
#include "OperationDO.h"

////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>	HdaFlowManager class manages the operations threads in the system </summary>
///
/// <remarks>	Etay Tchechanovski, 1/5/2012. </remarks>
////////////////////////////////////////////////////////////////////////////////////////////////////

class HdaFlowManager : public QObject
{
	Q_OBJECT

public:
	HdaFlowManager(QObject *parent);

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Create a thread for the given Page and OperationDOs. </summary>
	///
	/// <remarks>	Etay Tchechanovski, 1/5/2012. </remarks>
	/// <param name="page">	[in] The Page. </param>
	/// <param name="operations">	[in] The Operations. </param>
	/// <param name="probar">	[in] The ProgressBar. </param>
	////////////////////////////////////////////////////////////////////////////////////////////////////
	void addThread(Page* page,QVector<OperationDO*> operations,HdaProgressBar* probar);

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Gets the threads. </summary>
	///
	/// <remarks>	Etay Tchechanovski, 1/5/2012. </remarks>		
	/// <returns>	The threads. </returns>
	////////////////////////////////////////////////////////////////////////////////////////////////////
	QVector<HdaOperationThread*> getThreads();
	~HdaFlowManager();

private:
	QVector<HdaOperationThread*> _threads;

signals:
	void updatePage(Page*);

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Signals the parent to save and reload the project. </summary>
	///
	/// <remarks>	Etay Tchechanovski, 1/5/2012. </remarks>			
	////////////////////////////////////////////////////////////////////////////////////////////////////
	void callSaveAndReload();
public slots:	

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Remove given thread from the threads list. </summary>
	///
	/// <remarks>	Etay Tchechanovski, 1/5/2012. </remarks>			
	/// <param name="thread">	[in] The Thread. </param>
	////////////////////////////////////////////////////////////////////////////////////////////////////
	void removeThread(HdaOperationThread* thread);

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Save and reload the project. </summary>
	///
	/// <remarks>	Etay Tchechanovski, 1/5/2012. </remarks>			
	////////////////////////////////////////////////////////////////////////////////////////////////////
	void saveAndReload();
};

#endif // HDAFLOWMANAGER_H
